#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

int main(void) {
	pid_t pid = fork();
	if (pid > 0) {
		printf("父进程\n");
		int status = 0;
		waitpid(pid, &status, 0);
	} else if (pid == 0) {
		printf("子进程\n");
		char *argv[] = {"/bin/ping", "-c", "5", "www.baidu.com", NULL};
		char *envr[] = {NULL};
		int t = execve(argv[0], argv, envr);
		printf("t = %d执行命令失败\n", t);
	}
	printf("结束\n");
	return 0;
}